<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
	<meta name="renderer" content="webkit" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="apple-mobile-web-app-title" content="" />
	<meta name="format-detection" content="telephone=no,email=no,adress=no" />
	<link rel="stylesheet" type="text/css" href="css/test.css" />
	<script type="text/javascript" src="js/jquery-3.2.1.js"></script>
	<title>评价管理系统</title>
	<style type="text/css">
		body {
			width: 100%;
			height: 100%;
			overflow: hidden;
			background-color: #0f3090;
		}
	</style>
</head>

<body>
	<header class="headTop">
		<p>评价管理系统</p>
	</header>
	<section class="login">
		<figure>
			<img src="images/pick.png">
			<figcaption>评价管理系统</figcaption>
		</figure>

		<form action="">
			<article class="loginBox">
				<ul>
					<li><input id="account" type="text" placeholder="用户名" /></li>
					<li><input id="password" type="password" placeholder="密码" /></li>
				</ul>
				<button type="button" onclick="login()">登录</button>
				<button type="button" onclick="javascript:history.back(-1);">返回</button>
			</article>
		</form>

	</section>

	<script type="text/javascript">
		localStorage.removeItem('logined');
		window.addEventListener('pageshow', function( e ){
			if (e.persisted) {
				window.location.reload()
			}
		})
		function login() {
			var baseUrl = localStorage.getItem('baseUrl')
			var organ = JSON.parse(localStorage.getItem("organ"))
			var organizationId = organ.organizationId;
			var account = $('#account').val();
			var password = $('#password').val();
			$.ajax({
				url: baseUrl + '/user/login',
				method:'post',
				data: {
					//organizationId: organizationId,
					account: account,
					password: password
				},
				success: function (res) {
					console.log("登录", res);
					if (res.code === 200) {
						// 将用户缓存
						localStorage.setItem('user',JSON.stringify(res.data.user))
						localStorage.setItem('logined',"1")
						$(window).attr('location', 'loginIn.html');
					} else {
						alert(res.message)
					}
				}
			})
		}
	</script>
</body>

</html>